from .base_card import BasicCard
from typing import Dict, Any


class Summoner(BasicCard):
    """召唤师卡牌"""
    
    def __init__(self, card_id: str, name: str, image_path: str, description: str, hp: int):
        super().__init__(card_id, name, image_path, description)
        self.hp = hp
    
    def to_dict(self) -> Dict[str, Any]:
        """将召唤师序列化为字典"""
        data = super().to_dict()
        data.update({
            "type": "Summoner",  # 强制设置为Summoner，而不是子类名
            "hp": self.hp
        })
        return data
    
    def take_damage(self, damage: int) -> bool:
        """受到伤害，返回是否死亡"""
        self.hp = max(0, self.hp - damage)
        return self.hp <= 0
    
    def heal(self, amount: int):
        """恢复生命值（不设上限）"""
        self.hp += amount
    
    def is_alive(self) -> bool:
        """是否存活"""
        return self.hp > 0
